home *** CD-ROM | disk | FTP | other *** search
- Path: niamh.indigo.ie!usenet
- From: nsmart@indigo.ie (Niall Smart)
- Newsgroups: comp.lang.c
- Subject: Re: Settle a bet please
- Date: Fri, 05 Apr 1996 20:04:40 GMT
- Organization: None
- Message-ID: <4k41v6$60v@niamh.indigo.ie>
- References: <4jfopb$o9n@news1.sympatico.ca> <Dp11Bx.2o7@watserv3.uwaterloo.ca>
- NNTP-Posting-Host: dublin-ts7-156.indigo.ie
- X-Newsreader: Forte Free Agent 1.0.82
-
- bcrwhims@uwaterloo.ca (Carsten Whimster) wrote:
-
- [snip]
-
- > int i; char Name[7] = "My Name";
- > char More[] = "AAAAAAA";
-
- > for (i = 0; Name[i] != '\0'; i++)
- > putchar(Name[i]);
-
- >If you loop until you see a NULL, you might get "My NameAAAAAAA". There
- >may be some compiler variation there, but I am not sure about those.
- >I am only recently getting relatively familiar with C as a language,
- >never mind the platform dependencies. Actually, on my machine (OS/2 and
- >IBM VAC++), it prints out:
-
- >My Name\à
-
- >So obviously a NULL is needed. Interestingly, the "AAAAAAA" string is
- >not placed right after the Name string on my machine. Does anyone know
- >what the compiler might be doing here?
-
- char* More[] points to read-only memory containing "AAAAAAA", if you
- try to change what More is pointing to then the behaviour is
- undefined. The compiler is probably putting the "AAAAAAA" in a
- different data space because it is ROM.
-
- Niall
-
-
-